// const { series, parallel } = require('gulp');

// const task1 = done => {
//   setTimeout(() => {
//     console.log('task1 working~');
//     done();
//   }, 1000)
// }

// const task2 = done => {
//   setTimeout(() => {
//     console.log('task2 working~');
//     done();
//   }, 1000)
// }

// const task3 = done => {
//   setTimeout(() => {
//     console.log('task3 working~');
//     done();
//   }, 1000)
// }

// exports.foo = series(task1, task2, task3);
// exports.bar = parallel(task1, task2, task3);

// 1. 回调函数方式
exports.callback = done => {
  console.log('callback task~');
  done();
}

exports.callback_error = done => {
  console.log('callback error~');
  done(new Error('callback error'));
}

// 2. promise方式
exports.promise = () => {
  console.log('promise task~');
  return Promise.resolve();
}

exports.promise_error = () => {
  console.log('promise error~');
  return Promise.reject(new Error('promise error'));
}

// 3. async方式
const timeout = time => {
  return new Promise((resolve, reject) => {
    setTimeout(resolve, time);
  })
}
exports.async = async () => {
  await time(1000);
  console.log('async task~');
}